package com.wn.ziroom.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageInfo;
import com.wn.ziroom.entity.Production;
import com.wn.ziroom.entity.vo.ProductionVo;
import com.wn.ziroom.mapper.ProductionMapper;
import com.wn.ziroom.mapper.ProductionVoMapper;
import com.wn.ziroom.service.ProductionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Objects;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author wangzhijia
 * @since 2023-02-23 02:27:54
 */
@Service
public class ProductionServiceImpl extends ServiceImpl<ProductionMapper, Production> implements ProductionService {

    private ProductionVoMapper productionVoMapper;

    @Autowired
    public void setProductionMapper(ProductionVoMapper productionVoMapper) {
        this.productionVoMapper = productionVoMapper;
    }

    @Override
    public PageInfo<ProductionVo> listBootByPage(Integer now, Integer size, String productionName, String categoryId) {
        PageHelper.startPage(now,size);
        List<ProductionVo> productionVoList = productionVoMapper.selectPageByCondition(productionName,categoryId);
        return new PageInfo<>(productionVoList);
    }

    @Override
    public ProductionVo findProductionById(Integer productionId) {
        ProductionVo pro = productionVoMapper.selectProductionById(productionId);
        return pro;
    }


    /*@Override
    public Page<Production> listBootByPage(Integer now, Integer size, String condition) {
        Page<Production> productionPage = new Page<>(now,size);

        QueryWrapper<Production> queryWrapper = new QueryWrapper<>();
        queryWrapper.like(!Objects.isNull(condition),"production_name",condition);

        Page<Production> page = productionMapper.selectPage(productionPage, queryWrapper);
        return page;
    }*/
}
